package com.cmc.cloud.cmclink.doc.api.document.req.so.sovo.attachmentvo;

import com.cmc.cloud.cmclink.doc.util.so.CompareUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 订舱附件表 提单附件表 单证所有附件都保存在这张表 通过类型区分 Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 *
 * @author codegen
 */
@Data
public class AttachmentBaseVO {

    @Schema(description = "外键 so/ si id", example = "8804")
    private Long referenceId;

    @Schema(description = "业务类型 so/ si", example = "2")
    @Length(max = 20, message = "{attachment.referencetype.length}")
    private String referenceType;

    @Schema(description = "附件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
    @NotBlank(message = "{attachment.attachname.notblank}")
    @Length(max = 255, message = "{attachment.attachname.length}")
    private String attachName;

    @Schema(description = "文件类型", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{attachment.fileformat.notblank}")
    @Length(max = 50, message = "{attachment.fileformat.length}")
    private String fileFormat;
    @Schema(description = "附件类型", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "{attachment.attachtypecode.notblank}")
    @Length(max = 50, message = "{attachment.attachtypecode.length}")
    private String attachTypeCode;


    @Schema(description = "附件类型名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @Length(max = 50, message = "{attachment.attachtypename.length}")
    private String attachTypeName;
    @Schema(description = "附件类型名称中文", requiredMode = Schema.RequiredMode.REQUIRED)
    @Length(max = 50, message = "{attachment.attachtypenamecn.length}")
    private String attachTypeNameCn;

    @Schema(description = "附件类型名称英文", requiredMode = Schema.RequiredMode.REQUIRED)
    @Length(max = 50, message = "{attachment.attachtypenameen.length}")
    private String attachTypeNameEn;

    @Schema(description = "文件资源id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27182")
    @NotNull(message = "{attachment.fileid.notnull}")
    private Long fileId;

    public static CompareUtils<AttachmentBaseVO> getMultiFieldComparator() {
        return new CompareUtils<AttachmentBaseVO>().comparingField(AttachmentBaseVO::getReferenceType)
                .thenComparing(AttachmentBaseVO::getAttachName)
                .thenComparing(AttachmentBaseVO::getFileFormat)
                .thenComparing(AttachmentBaseVO::getAttachTypeCode)
                .thenComparing(AttachmentBaseVO::getAttachName)
                .thenComparing(AttachmentBaseVO::getFileId);
    }

}
